<include file="../header" />
<body class="J_scroll_fixed">
    <script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
    <script charset="utf-8" src="http://map.qq.com/api/js?v=2.exp&key=FO5BZ-2AC2G-ACAQV-I5BD3-YX65K-76BUB"></script>
    <script src="http://open.map.qq.com/apifiles/v1.0/app.js?v=1.0.131203.1" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {

            $('button#send').click(function () {
                var mobile = $("input[name=mobile]").val();
                var qq = $("input[name=qq]").val();
                var imageUrl = $("input[name=imageUrl]").val();

                if (qq === '' || qq === null) {
                    layer.msg('请填写用户qq!');
                    return false;
                }

                //验证手机号格式
                if (!mobileValidate($.trim(mobile))) {
                    layer.msg('请填写正确的手机号!');
                    return false;
                } else {
                    $("form#editUser").submit();
                }


                //验证用户头像图片上传
//            if(imageUrl===''||imageUrl===null) {
//                layer.msg('请选择文件上传用户头像!');
//                return false;
//            }

            });

            $("button#upload").click(function () {
                //上传文件
                $.ajaxFileUpload({
                    url: "{:U('shop/uploadImage')}", //处理图片脚本
                    secureuri: false,
                    fileElementId: 'fileToUpload', //file控件id
                    dataType: 'json',
                    success: function (data, status) {
                        $("input[name=imageUrl]").val(data);
//                    layer.msg(data);
                        $("img[name=preShow]").attr("src", data);
                    },
                    error: function (data, status, e) {
                        alert(e);
                    }
                })
            })

        });
    </script>
    <div class="wrap jj">
        <div class="common-form">
            <form  id='editUser' method="post" class="form-horizontal J_ajaxForm" action="{:U('customer/edit_post')}">
                <input type="hidden" name='id' value="{$user.user_id}" />
                <fieldset>
                    <div class="control-group">
                        <label class="control-label">qq:</label>
                        <div class="controls">
                            <input type="text" class="input" name="qq" value="{$user.qq}">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">手机号码:</label>
                        <div class="controls">
                            <input type="text" class="input" name="mobile" value="{$user.mobile}">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">Token:</label>
                        <div class="controls">
                            <input type="text" class="input" name="token" value="{$user.token}">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">状态:</label>
                        <div class="controls">
                            <select class="select" name="status">
                                <option value="1" selected>激活</option>
                                <option value="2">黑名单</option>
                            </select>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">用户头像:</label>
                        <div class="controls">
                            <input id="fileToUpload" type="file" name="fileToUpload" style="width:170px;">
                            <button type="button" class="btn btn-primary" id="upload">上传</button>
                            <input type="hidden" name="imageUrl" value="{$user.head_image_url}" />
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">头像预览:</label>
                        <div class="controls">
                            <img src="{$user.head_image_url}" name="preShow" style="width:200px;height:200px;" />
                        </div>
                    </div>

                </fieldset>

                <div class="form-actions">
                    <button id='send' type="button" class="btn btn-primary">更新</button>
                    <a class="btn" href="__URL__">返回</a>
                </div>
            </form>
        </div>
    </div>
    <script src="__ROOT__/statics/js/common.js"></script>
</body>
</html>